package com.sy.controller;

import com.sy.bean.PackageBean;
import com.sy.common.bean.ResultBean;
import com.sy.common.controller.BaseController;
import com.sy.service.PackageBeanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "套餐")
@RequestMapping("/api")
public class PackageBeanController extends BaseController {
    @Autowired
    PackageBeanService packageBeanService;

    @ApiOperation("更新套餐")
    @PostMapping("/package")
    public ResultBean edit(@RequestBody @Validated List<PackageBean> list, BindingResult result) {
        validate(result);
        int rs = packageBeanService.save(list);
        return gotoResult(rs, "更新");
    }
    @ApiOperation("套餐列表")
    @GetMapping("/package")
    public ResultBean<PackageBean> query(){
        List<PackageBean> list = packageBeanService.query();
        return success("套餐列表",list);
    }
}
